﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using FairyGUI;

namespace MDFGame
{
    public static class GameFactory
    {
        public static Entity CreateField(Dictionary<int,long>cardlist,UnOrderMultiMap<AreaType,long> arealist,UnOrderMultiMap<PlayerType,long>playerlist)
        {
            Field _field = EntityFactory.Create<Field>();
            FieldInfoComponent _fic = _field.AddComponent<FieldInfoComponent>();
            _fic.DescribeUIView = new DescribeUIView();
            _fic.DescribeUIView.Create(UIPackage.CreateObject("cardUI","DescribeArea").asCom);
            _fic.GameCard = cardlist;
            _fic.GameArea = arealist;
            _fic.GamePlayer = playerlist;
            _fic.NowState = GameState.GameStart;
            _fic.GameView = GameRoot.Scene.GetComponent<UIViewComponent>().ShowScene;
            _field.AddComponent<FieldBuffComponent>();
            return _field;
        }

        public static Entity CreatePlayer(PlayerType pt,Dictionary<int,long>cards,Dictionary<AreaType,long>areas,string name = "Unknown")
        {
            Player _player = EntityFactory.Create<Player>();
            PlayerInfoComponent _pic= _player.AddComponent<PlayerInfoComponent>();
            if (pt != PlayerType.Watcher)
            {
                PlayerEffectComponent _pec=_player.AddComponent<PlayerEffectComponent>();
                _pec.Active = true;
            }
            _pic.name = name;
            _pic.Player = pt;
            _pic.ControlCards = cards;
            _pic.ControlArea = areas;
            return _player;
        }
    }
}
